• Steven Ponce
  • About
  • Data Visualizations
  • Projects
  • Resume
  • Email

On this page

  • Steps to Create this Graphic
    • 1. Load Packages & Setup
    • 2. Read in the Data
    • 3. Examine the Data
    • 4. Tidy Data
    • 5. Visualization Parameters
    • 6. Plot
    • 7. Save
    • 8. Session Info
    • 9. GitHub Repository
    • 10. References

From Macarena to Bad Bunny: Latin Music’s Billboard Evolution

  • Show All Code
  • Hide All Code

  • View Source

Five cultural waves that transformed American popular music (1995-2022)

TidyTuesday
Data Visualization
R Programming
2025
Analyzing Latin music’s Billboard Hot 100 evolution from 1995-2022 through data visualization. This TidyTuesday project tracks five cultural waves that transformed American charts, from Macarena’s dance revolution to Bad Bunny’s streaming dominance, using R and ggplot2 to reveal Latin music’s path from crossover novelty to mainstream success.
Author

Steven Ponce

Published

August 25, 2025

Figure 1: Two-panel chart illustrating the evolution of Latin music on the Billboard charts from 1995 to 2022. The top timeline shows major hits, including “Despacito” (16 weeks) and “Macarena” (14 weeks), as peaks. Bottom-faceted bar charts display the top songs across five cultural waves: Dance Revolution (Macarena), Latin Pop Wave (Ricky Martin, Jennifer Lopez), Crossover Success (Santana), Streaming Era (Despacito), and Urban Takeover (Cardi B). Data demonstrates Latin music’s progression from novelty hits to mainstream dominance.)

Steps to Create this Graphic

1. Load Packages & Setup

Show code
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
    tidyverse,   # Easily Install and Load the 'Tidyverse'
    ggtext,      # Improved Text Rendering Support for 'ggplot2'
    showtext,    # Using Fonts More Easily in R Graphs
    janitor,     # Simple Tools for Examining and Cleaning Dirty Data
    scales,      # Scale Functions for Visualization
    glue,        # Interpreted String Literals,
    ggrepel,     # Automatically Position Non-Overlapping Text Labels with 'ggplot2' 
    patchwork    # The Composer of Plots
  )})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 10,
  height = 12,
  units  = "in",
  dpi    = 300
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

2. Read in the Data

Show code
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false

tt <- tidytuesdayR::tt_load(2025, week = 34)

billboard <- tt$billboard |> clean_names()
topics <- tt$topics |> clean_names()

tidytuesdayR::readme(tt)
rm(tt)
```

3. Examine the Data

Show code
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(billboard)
glimpse(topics)
```

4. Tidy Data

Show code
```{r}
#| label: tidy
#| warning: false

billboard_latin_clean <- billboard |>
  mutate(
    date = if (inherits(date, "Date")) date else as.Date(date),
    year = year(date),
    is_latin_country = artist_place_of_origin %in% c(
      "Mexico", "Puerto Rico", "Colombia", "Argentina", "Spain",
      "Cuba", "Dominican Republic", "Venezuela", "Peru", "Chile",
      "Ecuador", "Guatemala", "Costa Rica", "Panama", "Brazil"
    ),
    is_latin_artist = case_when(
      str_detect(tolower(artist), paste(c(
        "shakira", "ricky martin", "jennifer lopez|j\\.?lo", "marc anthony",
        "enrique iglesias", "luis fonsi", "daddy yankee", "ozuna|bad bunny|j balvin|maluma",
        "camila cabello|pitbull", "santana", "selena", "los del rio",
        "cardi b", "maroon 5"
      ), collapse = "|")) ~ TRUE,
      is_latin_country ~ TRUE,
      TRUE ~ FALSE
    ),
    spanish_language = case_when(
      str_detect(tolower(song), paste(c(
        "despacito", "macarena", "la vida loca", "gasolina", "danza kuduro", "baila", "amor", "corazón"
      ), collapse = "|")) ~ TRUE,
      foreign_language == 1 & is_latin_artist ~ TRUE,
      TRUE ~ FALSE
    )
  ) |>
  filter(is_latin_artist, !is.na(year), !is.na(weeks_at_number_one)) |>
  mutate(
    song_clean = case_when(
      str_detect(artist, "Los del Río") ~ "Macarena (Bayside Boys Mix)",
      str_detect(artist, "Santana ft. Rob Thomas") ~ "Smooth",
      str_detect(artist, "Santana") & !str_detect(artist, "ft.") ~ "Smooth",
      str_detect(artist, "Maroon 5 ft. Cardi B") ~ "Girls Like You",
      str_detect(artist, "Maroon 5") & year == 2012 ~ "One More Night",
      str_detect(artist, "Maroon 5") ~ "Girls Like You",
      str_detect(artist, "Pitbull ft. Kesha") ~ "Timber",
      str_detect(artist, "Jennifer Lopez ft. Ja Rule & Caddillac Tah") ~ "I'm Real",
      str_detect(artist, "Ricky Martin") ~ "Livin' La Vida Loca",
      str_detect(artist, "Jennifer Lopez") & !str_detect(artist, "ft.") ~ "All I Have",
      str_detect(artist, "Luis Fonsi & Daddy Yankee ft. Justin Bieber") ~ "Despacito",
      str_detect(artist, "Cardi B ft. Megan Thee Stallion") ~ "WAP",
      str_detect(artist, "Cardi B(?!,)|^Cardi B$") ~ "Bodak Yellow",
      str_detect(artist, "Cardi B, Bad Bunny, & J Balvin") ~ "I Like It",
      !is.na(song) & !is.logical(song) & song != "" ~ as.character(song),
      TRUE ~ NA_character_
    ),
    artist_clean = str_remove(artist, " feat.*|, feat.*|ft\\..*"),
    milestone_type = case_when(
      str_detect(tolower(song_clean), "macarena") ~ "Dance Revolution",
      str_detect(tolower(artist_clean), "ricky martin|jennifer lopez|marc anthony") ~ "Latin Pop Wave",
      str_detect(tolower(song_clean), "despacito") ~ "Streaming Era",
      str_detect(tolower(artist_clean), "cardi b|bad bunny|j balvin") ~ "Urban Takeover",
      TRUE ~ "Crossover Success"
    ),
    overall_rating = ifelse(is.na(overall_rating), median(overall_rating, na.rm = TRUE), overall_rating),
    song_display = if_else(!is.na(song_clean) & song_clean != "", song_clean, paste0("Hit by ", artist_clean)),
    artist_display = artist_clean
  ) |>
  filter(
    !is.na(artist_display),
    !str_detect(tolower(artist_display), "chris brown|bruno mars")
  ) |>
  distinct(artist, year, .keep_all = TRUE) |>
  arrange(year)

era_levels <- c(
  "Dance Revolution", "Latin Pop Wave", "Crossover Success",
  "Urban Takeover", "Streaming Era"
)

billboard_latin_clean <- billboard_latin_clean |>
  mutate(milestone_type = factor(milestone_type, levels = era_levels))

# P1: timeline chart data
timeline_data <- billboard_latin_clean |>
  mutate(
    label_show = ifelse(weeks_at_number_one >= 5, artist_display, NA_character_),
    label_face = ifelse(weeks_at_number_one >= 8, "bold", "plain")
  )

# P2: Faceted bars data
bars_data <- billboard_latin_clean |>
  mutate(
    clean_label = ifelse(!is.na(song_clean) & song_clean != "",
      glue("‘{song_clean}’\n{artist_display}"),
      artist_display
    )
  ) |>
  group_by(milestone_type) |>
  arrange(desc(weeks_at_number_one), desc(overall_rating)) |>
  distinct(artist_display, .keep_all = TRUE) |>
  slice_head(n = 4) |>
  ungroup()
```

5. Visualization Parameters

Show code
```{r}
#| label: params
#| include: true
#| warning: false

### |-  plot aesthetics ----
# Get basic theme colors
colors <- get_theme_colors()

palette_fill <- c(
  "Dance Revolution" = "#F39C12",
  "Latin Pop Wave" = "#2C7BB6",
  "Crossover Success" = "#7F8C8D",
  "Urban Takeover" = "#8E44AD",
  "Streaming Era" = "#12A15E"
)

palette_text <- c(
  "Dance Revolution" = "#C2700F",
  "Latin Pop Wave" = "#1D5B8C",
  "Crossover Success" = "#4F5A5E",
  "Urban Takeover" = "#6A2991",
  "Streaming Era" = "#0E7D49"
)


### |- titles and caption ----
title_text <- str_glue("From Macarena to Bad Bunny: Latin Music's Billboard Evolution")

subtitle_text <- str_glue(
  "Five cultural waves that transformed American popular music (1995-2022)"
)

caption_text <- create_social_caption(
  tt_year = 2025,
  tt_week = 34,
  source_text = "Billboard Hot 100 Number Ones"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----
# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    # Text styling
    plot.title = element_text(face = "bold", family = fonts$title, size = rel(1.2), color = colors$title, margin = margin(b = 10)),
    plot.subtitle = element_text(family = fonts$subtitle, lineheight = 1.2, color = colors$subtitle, size = rel(0.78), margin = margin(b = 20)),

    # Axis elements
    axis.line = element_blank(),
    axis.ticks = element_blank(),

    # Grid elements
    panel.grid.major = element_line(color = "gray90", linetype = "solid", linewidth = 0.3),
    # panel.grid.major.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    panel.grid.minor.y = element_blank(),

    # Axis elements
    axis.text = element_text(color = colors$text, size = rel(0.7)),
    axis.title.x = element_text(color = colors$text, face = "bold", size = rel(0.8), margin = margin(t = 15)),
    axis.title.y = element_text(color = colors$text, face = "bold", size = rel(0.8), margin = margin(r = 10)),

    # Legend elements
    legend.position = "plot",
    legend.title = element_text(family = fonts$tsubtitle, color = colors$text, size = rel(0.8), face = "bold"),
    legend.text = element_text(family = fonts$tsubtitle, color = colors$text, size = rel(0.7)),
    legend.margin = margin(t = 15),

    # Plot margin
    plot.margin = margin(t = 15, r = 15, b = 15, l = 15),
  )
)

# Set theme
theme_set(weekly_theme)
```

6. Plot

Show code
```{r}
#| label: plot
#| warning: false

# P1 timeline chart
p1 <- timeline_data |>
  ggplot(aes(x = year, y = weeks_at_number_one)) +
  # Geoms
  geom_point(aes(fill = milestone_type), shape = 21, color = "white", stroke = 1.2, alpha = 0.95, size = 5) +
  ggrepel::geom_text_repel(
    aes(label = label_show, color = milestone_type, fontface = label_face),
    family = "inter", size = 3.2, box.padding = 0.5, point.padding = 0.4,
    min.segment.length = 0.2, max.overlaps = 12, nudge_y = 1, segment.color = "grey60",
    show.legend = FALSE, seed = 43
  ) +
  # Scales
  scale_fill_manual(values = palette_fill, name = "Cultural Wave") +
  scale_color_manual(values = palette_text, guide = "none") +
  scale_x_continuous(breaks = seq(1995, 2020, 5), limits = c(1995, 2022)) +
  scale_y_continuous(breaks = seq(0, 16, 4), limits = c(0, 18), labels = \(x) paste0(x, " w")) +
  # Labs
  labs(
    title = "Five Waves That Took Latin Music to #1",
    subtitle = "A timeline of Billboard #1s (1995–2022) and the waves that carried them",
    x = "Year",
    y = "Weeks at Number One"
  )

# P2: faceted bars
p2 <- bars_data |>
  ggplot(aes(x = reorder(clean_label, weeks_at_number_one), y = weeks_at_number_one, fill = milestone_type)) +
  # Geoms
  geom_col(width = 0.65, alpha = 0.9) +
  geom_text(aes(label = paste0(weeks_at_number_one, "w")),
    hjust = -0.12,
    size = 3.1, color = "grey20", family = "inter", fontface = "bold"
  ) +
  # Scales
  scale_fill_manual(values = palette_fill, guide = "none") +
  coord_flip() +
  scale_y_continuous(expand = expansion(mult = c(0, 0.18))) +
  # Labs
  labs(
    title = "Top Hits by Cultural Wave",
    subtitle = "Each era’s biggest #1 streaks (weeks at number one)",
    x = NULL,
    y = "Weeks at Number One"
  ) +
  # Facets
  facet_wrap(~milestone_type, ncol = 2, scales = "free") +
  # Theme
  theme(
    panel.grid.major.y = element_blank(),
    panel.grid.minor = element_blank(),
    # panel.grid.major = element_blank(),  #element_line(color = "grey90", size = 0.3),
    strip.text = element_text(size = 10, face = "bold", color = "grey20"),
    strip.background = element_rect(fill = "grey90", color = NA),
    axis.text.y = element_text(size = 9),
    axis.text.x = element_text(size = 9),
  )

# Combined plots
combined_plots <- p1 / p2 +
  plot_layout(heights = c(1, 3))

combined_plots <- combined_plots +
  plot_annotation(
    title = title_text,
    subtitle = subtitle_text,
    caption = caption_text,
    theme = theme(
      plot.title = element_text(
        size = rel(1.7),
        family = fonts$title,
        face = "bold",
        color = colors$title,
        lineheight = 1.1,
        margin = margin(t = 5, b = 5)
      ),
      plot.subtitle = element_text(
        size = rel(1),
        family = fonts$subtitle,
        color = alpha(colors$subtitle, 0.9),
        lineheight = 1.2,
        margin = margin(t = 5, b = 10)
      ),
      plot.caption = element_markdown(
        size = rel(0.6),
        family = fonts$caption,
        color = colors$caption,
        hjust = 0.5,
        margin = margin(t = 10)
      )
    )
  )
```

7. Save

Show code
```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plots, 
  type = "tidytuesday", 
  year = 2025, 
  week = 34, 
  width  = 10,
  height = 12
  )
```

8. Session Info

Expand for Session Info
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] here_1.0.1      patchwork_1.3.0 ggrepel_0.9.6   glue_1.8.0     
 [5] scales_1.3.0    janitor_2.2.0   showtext_0.9-7  showtextdb_3.0 
 [9] sysfonts_0.8.9  ggtext_0.1.2    lubridate_1.9.3 forcats_1.0.0  
[13] stringr_1.5.1   dplyr_1.1.4     purrr_1.0.2     readr_2.1.5    
[17] tidyr_1.3.1     tibble_3.2.1    ggplot2_3.5.1   tidyverse_2.0.0
[21] pacman_0.5.1   

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       httr2_1.0.6        xfun_0.49          htmlwidgets_1.6.4 
 [5] gh_1.4.1           tzdb_0.5.0         vctrs_0.6.5        tools_4.4.0       
 [9] generics_0.1.3     parallel_4.4.0     curl_6.0.0         gifski_1.32.0-1   
[13] fansi_1.0.6        pkgconfig_2.0.3    lifecycle_1.0.4    compiler_4.4.0    
[17] farver_2.1.2       textshaping_0.4.0  munsell_0.5.1      codetools_0.2-20  
[21] snakecase_0.11.1   htmltools_0.5.8.1  yaml_2.3.10        crayon_1.5.3      
[25] pillar_1.9.0       camcorder_0.1.0    magick_2.8.5       commonmark_1.9.2  
[29] tidyselect_1.2.1   digest_0.6.37      stringi_1.8.4      labeling_0.4.3    
[33] rsvg_2.6.1         rprojroot_2.0.4    fastmap_1.2.0      grid_4.4.0        
[37] colorspace_2.1-1   cli_3.6.4          magrittr_2.0.3     utf8_1.2.4        
[41] withr_3.0.2        rappdirs_0.3.3     bit64_4.5.2        timechange_0.3.0  
[45] rmarkdown_2.29     tidytuesdayR_1.1.2 gitcreds_0.1.2     bit_4.5.0         
[49] ragg_1.3.3         hms_1.1.3          evaluate_1.0.1     knitr_1.49        
[53] markdown_1.13      rlang_1.1.6        gridtext_0.1.5     Rcpp_1.0.13-1     
[57] xml2_1.3.6         renv_1.0.3         vroom_1.6.5        svglite_2.1.3     
[61] rstudioapi_0.17.1  jsonlite_1.8.9     R6_2.5.1           systemfonts_1.1.0 

9. GitHub Repository

Expand for GitHub Repo

The complete code for this analysis is available in tt_2025_34.qmd.

For the full repository, click here.

10. References

Expand for References
  1. Data Sources:
  • TidyTuesday 2025 Week 34: [Billboard Hot 100 Number Ones](https://github.com/rfordatascience/tidytuesday/blob/main/data/2025/2025-08-26)
Back to top
Source Code
---
title: "From Macarena to Bad Bunny: Latin Music's Billboard Evolution"
subtitle: "Five cultural waves that transformed American popular music (1995-2022)"
description: "Analyzing Latin music's Billboard Hot 100 evolution from 1995-2022 through data visualization. This TidyTuesday project tracks five cultural waves that transformed American charts, from Macarena's dance revolution to Bad Bunny's streaming dominance, using R and ggplot2 to reveal Latin music's path from crossover novelty to mainstream success."
author: "Steven Ponce"
date: "2025-08-25" 
categories: ["TidyTuesday", "Data Visualization", "R Programming", "2025"]
tags: [
  "billboard",
  "latin-music", 
  "music-analysis",
  "cultural-trends",
  "chart-analysis",
  "ggplot2",
  "faceted-charts",
  "timeline-visualization",
  "music-industry",
  "cultural-impact",
  "streaming-era",
  "reggaeton",
  "data-storytelling"
]
image: "thumbnails/tt_2025_34.png"
format:
  html:
    toc: true
    toc-depth: 5
    code-link: true
    code-fold: true
    code-tools: true
    code-summary: "Show code"
    self-contained: true
    theme: 
      light: [flatly, assets/styling/custom_styles.scss]
      dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options: 
  chunk_output_type: inline
execute: 
  freeze: true                                    
  cache: true                                       
  error: false
  message: false
  warning: false
  eval: true
---

![Two-panel chart illustrating the evolution of Latin music on the Billboard charts from 1995 to 2022. The top timeline shows major hits, including "Despacito" (16 weeks) and "Macarena" (14 weeks), as peaks. Bottom-faceted bar charts display the top songs across five cultural waves: Dance Revolution (Macarena), Latin Pop Wave (Ricky Martin, Jennifer Lopez), Crossover Success (Santana), Streaming Era (Despacito), and Urban Takeover (Cardi B). Data demonstrates Latin music's progression from novelty hits to mainstream dominance.)](tt_2025_34.png){#fig-1}

### <mark> **Steps to Create this Graphic** </mark>

#### 1. Load Packages & Setup

```{r}
#| label: load
#| warning: false
#| message: false      
#| results: "hide"     

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
    tidyverse,   # Easily Install and Load the 'Tidyverse'
    ggtext,      # Improved Text Rendering Support for 'ggplot2'
    showtext,    # Using Fonts More Easily in R Graphs
    janitor,     # Simple Tools for Examining and Cleaning Dirty Data
    scales,      # Scale Functions for Visualization
    glue,        # Interpreted String Literals,
    ggrepel,     # Automatically Position Non-Overlapping Text Labels with 'ggplot2' 
    patchwork    # The Composer of Plots
  )})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 10,
  height = 12,
  units  = "in",
  dpi    = 300
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

#### 2. Read in the Data

```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false

tt <- tidytuesdayR::tt_load(2025, week = 34)

billboard <- tt$billboard |> clean_names()
topics <- tt$topics |> clean_names()

tidytuesdayR::readme(tt)
rm(tt)
```

#### 3. Examine the Data

```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(billboard)
glimpse(topics)
```

#### 4. Tidy Data

```{r}
#| label: tidy
#| warning: false

billboard_latin_clean <- billboard |>
  mutate(
    date = if (inherits(date, "Date")) date else as.Date(date),
    year = year(date),
    is_latin_country = artist_place_of_origin %in% c(
      "Mexico", "Puerto Rico", "Colombia", "Argentina", "Spain",
      "Cuba", "Dominican Republic", "Venezuela", "Peru", "Chile",
      "Ecuador", "Guatemala", "Costa Rica", "Panama", "Brazil"
    ),
    is_latin_artist = case_when(
      str_detect(tolower(artist), paste(c(
        "shakira", "ricky martin", "jennifer lopez|j\\.?lo", "marc anthony",
        "enrique iglesias", "luis fonsi", "daddy yankee", "ozuna|bad bunny|j balvin|maluma",
        "camila cabello|pitbull", "santana", "selena", "los del rio",
        "cardi b", "maroon 5"
      ), collapse = "|")) ~ TRUE,
      is_latin_country ~ TRUE,
      TRUE ~ FALSE
    ),
    spanish_language = case_when(
      str_detect(tolower(song), paste(c(
        "despacito", "macarena", "la vida loca", "gasolina", "danza kuduro", "baila", "amor", "corazón"
      ), collapse = "|")) ~ TRUE,
      foreign_language == 1 & is_latin_artist ~ TRUE,
      TRUE ~ FALSE
    )
  ) |>
  filter(is_latin_artist, !is.na(year), !is.na(weeks_at_number_one)) |>
  mutate(
    song_clean = case_when(
      str_detect(artist, "Los del Río") ~ "Macarena (Bayside Boys Mix)",
      str_detect(artist, "Santana ft. Rob Thomas") ~ "Smooth",
      str_detect(artist, "Santana") & !str_detect(artist, "ft.") ~ "Smooth",
      str_detect(artist, "Maroon 5 ft. Cardi B") ~ "Girls Like You",
      str_detect(artist, "Maroon 5") & year == 2012 ~ "One More Night",
      str_detect(artist, "Maroon 5") ~ "Girls Like You",
      str_detect(artist, "Pitbull ft. Kesha") ~ "Timber",
      str_detect(artist, "Jennifer Lopez ft. Ja Rule & Caddillac Tah") ~ "I'm Real",
      str_detect(artist, "Ricky Martin") ~ "Livin' La Vida Loca",
      str_detect(artist, "Jennifer Lopez") & !str_detect(artist, "ft.") ~ "All I Have",
      str_detect(artist, "Luis Fonsi & Daddy Yankee ft. Justin Bieber") ~ "Despacito",
      str_detect(artist, "Cardi B ft. Megan Thee Stallion") ~ "WAP",
      str_detect(artist, "Cardi B(?!,)|^Cardi B$") ~ "Bodak Yellow",
      str_detect(artist, "Cardi B, Bad Bunny, & J Balvin") ~ "I Like It",
      !is.na(song) & !is.logical(song) & song != "" ~ as.character(song),
      TRUE ~ NA_character_
    ),
    artist_clean = str_remove(artist, " feat.*|, feat.*|ft\\..*"),
    milestone_type = case_when(
      str_detect(tolower(song_clean), "macarena") ~ "Dance Revolution",
      str_detect(tolower(artist_clean), "ricky martin|jennifer lopez|marc anthony") ~ "Latin Pop Wave",
      str_detect(tolower(song_clean), "despacito") ~ "Streaming Era",
      str_detect(tolower(artist_clean), "cardi b|bad bunny|j balvin") ~ "Urban Takeover",
      TRUE ~ "Crossover Success"
    ),
    overall_rating = ifelse(is.na(overall_rating), median(overall_rating, na.rm = TRUE), overall_rating),
    song_display = if_else(!is.na(song_clean) & song_clean != "", song_clean, paste0("Hit by ", artist_clean)),
    artist_display = artist_clean
  ) |>
  filter(
    !is.na(artist_display),
    !str_detect(tolower(artist_display), "chris brown|bruno mars")
  ) |>
  distinct(artist, year, .keep_all = TRUE) |>
  arrange(year)

era_levels <- c(
  "Dance Revolution", "Latin Pop Wave", "Crossover Success",
  "Urban Takeover", "Streaming Era"
)

billboard_latin_clean <- billboard_latin_clean |>
  mutate(milestone_type = factor(milestone_type, levels = era_levels))

# P1: timeline chart data
timeline_data <- billboard_latin_clean |>
  mutate(
    label_show = ifelse(weeks_at_number_one >= 5, artist_display, NA_character_),
    label_face = ifelse(weeks_at_number_one >= 8, "bold", "plain")
  )

# P2: Faceted bars data
bars_data <- billboard_latin_clean |>
  mutate(
    clean_label = ifelse(!is.na(song_clean) & song_clean != "",
      glue("‘{song_clean}’\n{artist_display}"),
      artist_display
    )
  ) |>
  group_by(milestone_type) |>
  arrange(desc(weeks_at_number_one), desc(overall_rating)) |>
  distinct(artist_display, .keep_all = TRUE) |>
  slice_head(n = 4) |>
  ungroup()
```

#### 5. Visualization Parameters

```{r}
#| label: params
#| include: true
#| warning: false

### |-  plot aesthetics ----
# Get basic theme colors
colors <- get_theme_colors()

palette_fill <- c(
  "Dance Revolution" = "#F39C12",
  "Latin Pop Wave" = "#2C7BB6",
  "Crossover Success" = "#7F8C8D",
  "Urban Takeover" = "#8E44AD",
  "Streaming Era" = "#12A15E"
)

palette_text <- c(
  "Dance Revolution" = "#C2700F",
  "Latin Pop Wave" = "#1D5B8C",
  "Crossover Success" = "#4F5A5E",
  "Urban Takeover" = "#6A2991",
  "Streaming Era" = "#0E7D49"
)


### |- titles and caption ----
title_text <- str_glue("From Macarena to Bad Bunny: Latin Music's Billboard Evolution")

subtitle_text <- str_glue(
  "Five cultural waves that transformed American popular music (1995-2022)"
)

caption_text <- create_social_caption(
  tt_year = 2025,
  tt_week = 34,
  source_text = "Billboard Hot 100 Number Ones"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----
# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    # Text styling
    plot.title = element_text(face = "bold", family = fonts$title, size = rel(1.2), color = colors$title, margin = margin(b = 10)),
    plot.subtitle = element_text(family = fonts$subtitle, lineheight = 1.2, color = colors$subtitle, size = rel(0.78), margin = margin(b = 20)),

    # Axis elements
    axis.line = element_blank(),
    axis.ticks = element_blank(),

    # Grid elements
    panel.grid.major = element_line(color = "gray90", linetype = "solid", linewidth = 0.3),
    # panel.grid.major.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    panel.grid.minor.y = element_blank(),

    # Axis elements
    axis.text = element_text(color = colors$text, size = rel(0.7)),
    axis.title.x = element_text(color = colors$text, face = "bold", size = rel(0.8), margin = margin(t = 15)),
    axis.title.y = element_text(color = colors$text, face = "bold", size = rel(0.8), margin = margin(r = 10)),

    # Legend elements
    legend.position = "plot",
    legend.title = element_text(family = fonts$tsubtitle, color = colors$text, size = rel(0.8), face = "bold"),
    legend.text = element_text(family = fonts$tsubtitle, color = colors$text, size = rel(0.7)),
    legend.margin = margin(t = 15),

    # Plot margin
    plot.margin = margin(t = 15, r = 15, b = 15, l = 15),
  )
)

# Set theme
theme_set(weekly_theme)
```

#### 6. Plot

```{r}
#| label: plot
#| warning: false

# P1 timeline chart
p1 <- timeline_data |>
  ggplot(aes(x = year, y = weeks_at_number_one)) +
  # Geoms
  geom_point(aes(fill = milestone_type), shape = 21, color = "white", stroke = 1.2, alpha = 0.95, size = 5) +
  ggrepel::geom_text_repel(
    aes(label = label_show, color = milestone_type, fontface = label_face),
    family = "inter", size = 3.2, box.padding = 0.5, point.padding = 0.4,
    min.segment.length = 0.2, max.overlaps = 12, nudge_y = 1, segment.color = "grey60",
    show.legend = FALSE, seed = 43
  ) +
  # Scales
  scale_fill_manual(values = palette_fill, name = "Cultural Wave") +
  scale_color_manual(values = palette_text, guide = "none") +
  scale_x_continuous(breaks = seq(1995, 2020, 5), limits = c(1995, 2022)) +
  scale_y_continuous(breaks = seq(0, 16, 4), limits = c(0, 18), labels = \(x) paste0(x, " w")) +
  # Labs
  labs(
    title = "Five Waves That Took Latin Music to #1",
    subtitle = "A timeline of Billboard #1s (1995–2022) and the waves that carried them",
    x = "Year",
    y = "Weeks at Number One"
  )

# P2: faceted bars
p2 <- bars_data |>
  ggplot(aes(x = reorder(clean_label, weeks_at_number_one), y = weeks_at_number_one, fill = milestone_type)) +
  # Geoms
  geom_col(width = 0.65, alpha = 0.9) +
  geom_text(aes(label = paste0(weeks_at_number_one, "w")),
    hjust = -0.12,
    size = 3.1, color = "grey20", family = "inter", fontface = "bold"
  ) +
  # Scales
  scale_fill_manual(values = palette_fill, guide = "none") +
  coord_flip() +
  scale_y_continuous(expand = expansion(mult = c(0, 0.18))) +
  # Labs
  labs(
    title = "Top Hits by Cultural Wave",
    subtitle = "Each era’s biggest #1 streaks (weeks at number one)",
    x = NULL,
    y = "Weeks at Number One"
  ) +
  # Facets
  facet_wrap(~milestone_type, ncol = 2, scales = "free") +
  # Theme
  theme(
    panel.grid.major.y = element_blank(),
    panel.grid.minor = element_blank(),
    # panel.grid.major = element_blank(),  #element_line(color = "grey90", size = 0.3),
    strip.text = element_text(size = 10, face = "bold", color = "grey20"),
    strip.background = element_rect(fill = "grey90", color = NA),
    axis.text.y = element_text(size = 9),
    axis.text.x = element_text(size = 9),
  )

# Combined plots
combined_plots <- p1 / p2 +
  plot_layout(heights = c(1, 3))

combined_plots <- combined_plots +
  plot_annotation(
    title = title_text,
    subtitle = subtitle_text,
    caption = caption_text,
    theme = theme(
      plot.title = element_text(
        size = rel(1.7),
        family = fonts$title,
        face = "bold",
        color = colors$title,
        lineheight = 1.1,
        margin = margin(t = 5, b = 5)
      ),
      plot.subtitle = element_text(
        size = rel(1),
        family = fonts$subtitle,
        color = alpha(colors$subtitle, 0.9),
        lineheight = 1.2,
        margin = margin(t = 5, b = 10)
      ),
      plot.caption = element_markdown(
        size = rel(0.6),
        family = fonts$caption,
        color = colors$caption,
        hjust = 0.5,
        margin = margin(t = 10)
      )
    )
  )
```

#### 7. Save

```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plots, 
  type = "tidytuesday", 
  year = 2025, 
  week = 34, 
  width  = 10,
  height = 12
  )
```

#### 8. Session Info

::: {.callout-tip collapse="true"}
##### Expand for Session Info

```{r, echo = FALSE}
#| eval: true
#| warning: false

sessionInfo()
```
:::

#### 9. GitHub Repository

::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo

The complete code for this analysis is available in [`tt_2025_34.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2025/tt_2025_34.qmd).

For the full repository, [click here](https://github.com/poncest/personal-website/).
:::

#### 10. References

::: {.callout-tip collapse="true"}
##### Expand for References

1.  Data Sources:

-   TidyTuesday 2025 Week 34: \[Billboard Hot 100 Number Ones\](https://github.com/rfordatascience/tidytuesday/blob/main/data/2025/2025-08-26)
:::

© 2024 Steven Ponce

Source Issues